package spring6.iocxml.bean;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestUser {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        //根据id获取bean
        User user = (User)context.getBean("user");
        System.out.println("根据ID获取bean："+user);
        //根据类型获取bean
        User user2 = context.getBean(User.class);
        System.out.println("根据类型获得bean："+user2);
        //根据id与类型
        User user3 = (User)context.getBean("user",User.class);
        System.out.println("根据类型与id获得bean："+user3);
    }
}
